export default {
    data() {
        return {
            lineChartData: [
                {
                    name: 'CH4',
                    type: 'line',
                    sysbom: 'none',
                    smooth: true,
                    lineStyle: {
                        width: 3,
                    },
                    data: [],
                },
                {
                    name: 'H2S',
                    type: 'line',
                    smooth: true,
                    lineStyle: {
                        width: 3,
                    },
                    data: [],
                },
                {
                    name: 'CO',
                    type: 'line',
                    smooth: true,
                    lineStyle: {
                        width: 3,
                    },
                    data: [],
                },
                {
                    name: 'O2',
                    type: 'line',
                    smooth: true,
                    lineStyle: {
                        width: 3,
                    },
                    data: [],
                },
            ],
            lineChartOption: {
                grid: {
                    top: 40,
                    right: 20,
                },
                xAxis: {
                    type: 'category',
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#D9D9D9',
                        },
                    },
                    axisLabel: {
                        margin: 25,
                        color: '#594942',
                    },
                    axisTick: {
                        show: false, // 是否显示刻度线
                        alignWithLabel: true,
                        lineStyle: {
                            color: '#D9D9D9',
                        },
                    },
                    data: [],
                },
                yAxis: {
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#D9D9D9',
                        },
                    },
                    axisLabel: {
                        margin: 15,
                        color: '#594942',
                    },
                    axisTick: {
                        show: false, // 是否显示刻度线
                        alignWithLabel: true,
                    },
                    splitLine: {
                        // 网格线
                        lineStyle: {
                            type: 'dashed', // 设置网格线类型 dotted：虚线   solid:实线
                        },
                        show: false, // 隐藏或显示
                    },
                },
                color: ['#FFB13C', '#38C914', '#FF8D8D', '#1D5ED3'],
                legend: {
                    icon: 'circle',
                    itemWidth: 10,
                    itemGap: 10,
                    right: 20,
                    data: ['CH4', 'H2S', 'CO', 'O2'],
                },
            },
            barChartData: [{
                data: [150, 42],
                type: 'bar',
                itemStyle: {
                    color: function(params) {
                        // 定制颜色
                        if (params.dataIndex === 0) {
                            return '#38C914';
                        } else {
                            return '#D41E1E';
                        }
                    },
                    // barBorderRadius: [0],
                },
                barWidth: 15,
                // tooltip: {
                //     valueFormatter: function(value) {
                //         return value + '项目数';
                //     }
                // },
            }],
            barChartOption: {
                grid: {
                    top:0,
                    left: 50,
                    right:20,
                },
                legend: {
                    itemWidth: 10,
                    itemHeight: 10,
                    itemGap: 20,
                    left: 'center',
                    data: [this.$t('confinedSpace.global.online'), this.$t('confinedSpace.global.offline')],
                },
                yAxis: {
                    type: 'category',
                    inverse: true, //反向
                    axisTick: {
                        show: false, // 是否显示刻度线 默认为true
                        alignWithLabel: true,
                        lineStyle: {
                            color: '#D9D9D9',
                        },
                    },
                    axisLine: {
                        show: false,
                        lineStyle: {
                            color: '#D9D9D9',
                        },
                    },
                    axisLabel: {
                        margin: 20,
                        show: true,
                        color: '#594942',
                        formatter: function(value) {
                            let valueTxt = value
                            let maxLength = 7
                            if(value.length>maxLength){
                                valueTxt = valueTxt.substring(0, maxLength) + "\n" + valueTxt.substring(maxLength);
                            }
                            return valueTxt
                        }
                    },
                    data: [this.$t('confinedSpace.global.online'), this.$t('confinedSpace.global.offline')],
                },
                xAxis: {
                    type: 'value',
                    boundaryGap: [0, 0.01],
                    minInterval: 1,
                    axisLine: {
                        show: true,
                        lineStyle: {
                            type: 'solid',
                            color:'#D3D3D3'
                        },
                    },
                    axisTick: {
                        show: false, // 是否显示刻度线 默认为true
                    },
                    splitLine: {
                        // 网格线
                        lineStyle: {
                            type: 'solid', // 设置网格线类型 dotted：虚线   solid:实线
                        },
                        show: false, // 隐藏或显示
                    },
                    axisLabel: {
                        show:true,
                        formatter: '{value}' //右侧label
                    }
                },
            },
        }
    }
}